const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}
const isProEnv = process.env.NODE_ENV === 'production'
module.exports = {
	publicPath: isProEnv ? './' : '/',
  productionSourceMap: false,
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@$', resolve('src'))
      .set('@assets', resolve('src/assets'))

    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule
      .oneOf('inline')
      .resourceQuery(/inline/)
      .use('vue-svg-icon-loader')
      .loader('vue-svg-icon-loader')
      .end()
      .end()
      .oneOf('external')
      .use('file-loader')
      .loader('file-loader')
      .options({
        name: 'assets/[name].[hash:8].[ext]'
      })
  },
	pluginOptions: {
		'style-resources-loader': {
			preProcessor: 'sass',
			patterns: [
				resolve('./src/uni.less')
			]
		}
	},
	devServer: {
		port: 3001,
		proxy: {
			'/pro': {
				target: 'http://39.105.191.22:8080/dt',
				ws: false,
				changeOrigin: true,
				pathRewrite: {
					'/pro': '' // 默认所有请求都加了/pro前缀，需要去掉
				}
			}
		}
		// 调试时允许内网穿透，让外网的人访问到本地调试的H5页面
		// disableHostCheck: true
	},
  lintOnSave: true
}
